package com.hmy.contract.service.contract.save.supply;

import cn.hutool.extra.spring.SpringUtil;
import com.hmy.ccp.error.exception.HMYRuntimeException;
import com.hmy.contract.commons.enums.ContractTypeEnum;
import com.hmy.contract.service.contract.save.supply.impl.SaveElectronicSupplyContractService;
import com.hmy.contract.service.contract.save.supply.impl.SavePaperSupplyContractService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author seven.qi 齐胜南
 * @version 1.0
 * @description
 * @date 2023/12/23 16:12
 */
@Slf4j
@Component
public class SaveSupplyContractServiceFactory {

    public static ISaveSupplyContractService getInstance(Integer type) {
        if (ContractTypeEnum.ELECTRONIC_CONTRACT.getType().equals(type)) {
            return SpringUtil.getBean(SaveElectronicSupplyContractService.class);
        } else if (ContractTypeEnum.PAPER_CONTRACT.getType().equals(type)) {
            return SpringUtil.getBean(SavePaperSupplyContractService.class);
        } else {
            log.error("{} : not support", type);
            throw new HMYRuntimeException(502000031);
        }
    }
}
